package com.agile.leetcode.hutool.concurrnceytest;

import cn.hutool.core.lang.Console;
import cn.hutool.core.thread.ConcurrencyTester;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.RandomUtil;

/**
 * @Author：chenzhangkun
 * @Date：2023/11/1 14:11
 */
public class ConcurrencyTesterDemo {

    public static void main(String[] args) {

        ConcurrencyTester concurrencyTester = ThreadUtil.concurrencyTest(100, () -> {
            // 测试的逻辑内容
            long delay = RandomUtil.randomLong(100, 1000);
            ThreadUtil.sleep(delay);
            Console.log("{} test finished, delay: {}", Thread.currentThread().getName(), delay);
        });
        // 获取总的执行时间
        Console.log(concurrencyTester.getInterval());
    }
}
